'use strict';
const {
  Model, INTEGER
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  // class driver extends Model {
  //   /**
  //    * Helper method for defining associations.
  //    * This method is not a part of Sequelize lifecycle.
  //    * The `models/index` file will call this method automatically.
  //    */
  //   static associate(models) {
  //     // define association here
  //   }
  // };
  const Fleet=sequelize.define('Fleet',{
    FleetID:{
        allowNull: false,
        primaryKey: true,
        autoIncrement:true,
        type: DataTypes.INTEGER,
      },
    FleetAccountName:{
      type:DataTypes.STRING,
    },
    FleetAccountPwd:{
      type:DataTypes.STRING,
    },
    FleetCode:{
      type:DataTypes.STRING,
    },
    FleetCName:{
      type:DataTypes.STRING,
    },
    FleetContact:{
      type:DataTypes.STRING,
    },
    FleetPic:{
      type:DataTypes.INTEGER,
    },
    Status:{
      type:DataTypes.INTEGER,
    },
    TimeReg:{
      type:DataTypes.DATE()
    },
    TimeAgree:{
      type:DataTypes.DATE(),
    },
    TimeLastLogin:{
      type:DataTypes.DATE(),
    },
    FilePath:{
        type:DataTypes.STRING
    }
},{
    timestamps:false
});
Fleet.associate=function(models){
    Fleet.hasMany(models.der,{
      foreignKey:'FleetID',
      sourceKey:'FleetID'
    }),
    Fleet.hasMany(models.truck,{
        foreignKey:'FleetID',
        sourceKey:'FleetID'
      })
  }
  return Fleet;
};